<?php

// pclzip.lib.php使用说明：http://www.ccvita.com/10.html

// 生成压缩文件
set_time_limit ( 0 );
include_once ('zip.lib.php');

function getDir($dir) {
	global $fs;
	$handle = opendir ( $dir );
	while ( false !== $file = (readdir ( $handle )) ) {
		if ($file !== '.' && $file != '..' && $file != '.svn' && strpos ( $file, '.zip' ) === false && strpos ( $file, '.tpl.php' ) === false) {
			// echo $file . "<br/>";
			if (is_file ( $dir . $file )) {
				$fs .= $dir . $file . ",";
				if (strpos ( $file, '.' ) === false) {
				}
			} else {
				getDir ( $dir . $file . "/" );
			}
		
		}
	}
	closedir ( $handle );
}

$start = explode ( ' ', microtime () );
echo $start [1] . "<br/>";
// $dir = '../ads/adfiles/';
$dir = '../../../admin/';

$fs = "";

getDir ( $dir );

file_put_contents ( "zip.txt", $fs );
// echo "success";
// die();

$f = explode ( ",", $fs );
$zipfile = 'zip.zip';
$archive = new PclZip ( $zipfile );
$v_list = $archive->create ( $fs );
if ($v_list == 0) {
	die ( "Error : " . $archive->errorInfo ( true ) );
}

$end = explode ( ' ', microtime () );
echo $end [1];
echo "<br/>" . ($end [1] - $start [1]);
echo "<br/>success";

?>	